package org.yaukie.websocket.configure;

import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
import org.yaukie.websocket.handler.WebSocketHander;
import org.yaukie.websocket.interceptor.HandshakeInterceptor;

public class SpringWebSocketConfig  extends WebMvcConfigurerAdapter implements WebSocketConfigurer{

	@Override
	public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
		registry.addHandler(webSocketHandler(), "/websocket.do")
		.addInterceptors(new HandshakeInterceptor());
		registry.addHandler(this.webSocketHandler(), "/webjs/socket.do")
		.addInterceptors(new HandshakeInterceptor());
	}
	
	@Bean
	private WebSocketHander webSocketHandler(){
		return new 	WebSocketHander();
	}

}
